/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jTFuncionario.java
 *
 * Created on 10/11/2009, 00:49:25
 */

package restaurante.forms;

import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import restaurante.dao.ProdutoDao;
import restaurante.logica.Produto;

/**
 *
 * @author Fernanda
 */
public class jFCadProduto extends javax.swing.JFrame {

    /** Creates new form jTFuncionario */
    public jFCadProduto() throws SQLException {
        
        initComponents();
        populaTabela("");
        desabilitaDados();
        desabilitarVisaoTodos();
    }

    DefaultTableModel tmProduto = new DefaultTableModel(
            new Object [][]{
            },
            new String[]{"id", "nome","preco_venda","tamanho"});
    
    private List<Produto> produtos;
    ListSelectionModel lsmProduto;

    public void populaTabela(String busca) throws SQLException{

        ProdutoDao pd = new ProdutoDao();
        produtos = pd.getLista("%"+busca+"%");
        
        for (Produto p1 : produtos) {
            insereTabela(p1);
        }
    }

    public void insereTabela(Produto p1){

        tmProduto.addRow(new String[]{
            String.valueOf(p1.getId()),
            p1.getNome(),
            String.valueOf(p1.getPreco_venda()),
            String.valueOf(p1.getTamanho()),
        });
    }




    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPCadProduto = new javax.swing.JPanel();
        jPPesquisaNome = new javax.swing.JPanel();
        jBPesquisa = new javax.swing.JButton();
        jTPesquisa = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jLID = new javax.swing.JLabel();
        jLNome = new javax.swing.JLabel();
        jLMarca = new javax.swing.JLabel();
        jLEstoque = new javax.swing.JLabel();
        jTID = new javax.swing.JTextField();
        jTNome = new javax.swing.JTextField();
        jTPreco_venda = new javax.swing.JTextField();
        jTTamanho = new javax.swing.JTextField();
        jBSalvar = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jBSair = new javax.swing.JButton();
        jBExcluir = new javax.swing.JButton();
        jBAlterar = new javax.swing.JButton();
        jBNovo = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTProduto = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(255, 255, 255));
        setBounds(new java.awt.Rectangle(354, 124, 600, 600));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setForeground(new java.awt.Color(255, 255, 255));
        setIconImages(null);
        setUndecorated(true);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPCadProduto.setBackground(new java.awt.Color(102, 255, 204));
        jPCadProduto.setAlignmentX(0.0F);
        jPCadProduto.setAlignmentY(0.0F);
        jPCadProduto.setPreferredSize(new java.awt.Dimension(600, 600));

        jPPesquisaNome.setBackground(new java.awt.Color(255, 255, 255));
        jPPesquisaNome.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Pesquisa pelo Nome do Produto", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 18))); // NOI18N
        jPPesquisaNome.setPreferredSize(new java.awt.Dimension(580, 61));

        jBPesquisa.setText("Pesquisa");
        jBPesquisa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBPesquisaActionPerformed(evt);
            }
        });

        jTPesquisa.setHorizontalAlignment(javax.swing.JTextField.LEFT);

        javax.swing.GroupLayout jPPesquisaNomeLayout = new javax.swing.GroupLayout(jPPesquisaNome);
        jPPesquisaNome.setLayout(jPPesquisaNomeLayout);
        jPPesquisaNomeLayout.setHorizontalGroup(
            jPPesquisaNomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPPesquisaNomeLayout.createSequentialGroup()
                .addContainerGap(173, Short.MAX_VALUE)
                .addComponent(jTPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBPesquisa)
                .addGap(24, 24, 24))
        );
        jPPesquisaNomeLayout.setVerticalGroup(
            jPPesquisaNomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPPesquisaNomeLayout.createSequentialGroup()
                .addGroup(jPPesquisaNomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBPesquisa))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Cadastro do Produto", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 18))); // NOI18N

        jLID.setText("ID:");

        jLNome.setText("Nome:");

        jLMarca.setText("Preço de Venda");

        jLEstoque.setText("Tamanho");

        jTNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTNomeActionPerformed(evt);
            }
        });

        jTPreco_venda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTPreco_vendaActionPerformed(evt);
            }
        });

        jTTamanho.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTTamanhoActionPerformed(evt);
            }
        });

        jBSalvar.setText("SALVAR MODIFICAÇÃO");
        jBSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSalvarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLID)
                            .addComponent(jLMarca)
                            .addComponent(jLEstoque))
                        .addGap(30, 30, 30)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jTID, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLNome)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTNome, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
                                .addGap(163, 163, 163))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jTPreco_venda, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
                                        .addGap(86, 86, 86))
                                    .addComponent(jTTamanho, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(115, 115, 115)))
                        .addContainerGap())
                    .addComponent(jBSalvar, javax.swing.GroupLayout.Alignment.TRAILING)))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLID)
                    .addComponent(jTNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLNome))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLMarca)
                    .addComponent(jTPreco_venda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTTamanho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLEstoque))
                .addGap(22, 22, 22))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(57, Short.MAX_VALUE)
                .addComponent(jBSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jBSair.setText("Sair");
        jBSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSairActionPerformed(evt);
            }
        });

        jBExcluir.setText("EXCLUIR PRODUTO");
        jBExcluir.setPreferredSize(new java.awt.Dimension(100, 25));
        jBExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBExcluirActionPerformed(evt);
            }
        });

        jBAlterar.setText("ALTERAR DADOS");
        jBAlterar.setPreferredSize(new java.awt.Dimension(100, 25));
        jBAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBAlterarActionPerformed(evt);
            }
        });

        jBNovo.setText("CADASTRAR NOVO");
        jBNovo.setPreferredSize(new java.awt.Dimension(100, 25));
        jBNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBNovoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jBNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jBExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jBAlterar, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jBSair, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jBSair)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jBNovo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jBExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jBAlterar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jTProduto.setModel(tmProduto);
        jTProduto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTProdutoMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTProduto);

        javax.swing.GroupLayout jPCadProdutoLayout = new javax.swing.GroupLayout(jPCadProduto);
        jPCadProduto.setLayout(jPCadProdutoLayout);
        jPCadProdutoLayout.setHorizontalGroup(
            jPCadProdutoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPCadProdutoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPCadProdutoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPPesquisaNome, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPCadProdutoLayout.setVerticalGroup(
            jPCadProdutoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPCadProdutoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPPesquisaNome, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
                .addContainerGap())
        );

        getContentPane().add(jPCadProduto, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
        jPCadProduto.getAccessibleContext().setAccessibleName("CadastroFuncionario");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTNomeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTNomeActionPerformed

    private void jTPreco_vendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTPreco_vendaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTPreco_vendaActionPerformed

    private void jBNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBNovoActionPerformed
        limparCampos();
        jTID.setText("");
        habilitaDados();

    }//GEN-LAST:event_jBNovoActionPerformed

    private void jBSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSalvarActionPerformed

        if (verificaDados()){
            novoCadastro();
            limparCampos();
            desabilitaDados();
        }
    }//GEN-LAST:event_jBSalvarActionPerformed

    private void jBSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSairActionPerformed
        this.dispose();
        //jTFuncionario.
        // TODO add your handling code here:
    }//GEN-LAST:event_jBSairActionPerformed

    private void jBAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAlterarActionPerformed

        if (verificaDados()){
            alteraCadastro();
            limparCampos();
            desabilitaDados();
        }
    }//GEN-LAST:event_jBAlterarActionPerformed

    private void jTProdutoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTProdutoMouseClicked

        habilitaDados();
        escolherLinha();
        // TODO add your handling code here:
    }//GEN-LAST:event_jTProdutoMouseClicked

    private void jBExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBExcluirActionPerformed

        removerCadastro();

    }//GEN-LAST:event_jBExcluirActionPerformed

    private void jBPesquisaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBPesquisaActionPerformed
        try {
            tmProduto.setNumRows(0);
            populaTabela(jTPesquisa.getText());
        } catch (SQLException ex) {
            Logger.getLogger(jFCadProduto.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jBPesquisaActionPerformed

    private void jTTamanhoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTTamanhoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTTamanhoActionPerformed


    public void desabilitarVisaoTodos(){

        //jPFundoCadastro.setVisible(false);
        //jPCadFuncionario.setVisible(false);

    }

    private void escolherLinha(){

        int linha = jTProduto.getSelectedRow();
        System.out.println(linha);

        Produto p1 = new Produto();
        String temp;

            temp = String.valueOf(jTProduto.getValueAt(linha, 0));
        p1.setId(Integer.parseInt(temp));
        p1.setNome(String.valueOf(jTProduto.getValueAt(linha,1)));
            temp = String.valueOf(jTProduto.getValueAt(linha, 2));
        p1.setPreco_venda(Float.parseFloat(temp));
        p1.setTamanho(String.valueOf(jTProduto.getValueAt(linha, 3)));

        escreverJTextField(p1);
        
    }

    private void escreverJTextField(Produto i1){

        System.out.println(i1);

        jTID.setEditable(true);
        jTID.setText(String.valueOf(i1.getId()));
        jTID.setEditable(false);

        jTNome.setText(i1.getNome());
        jTPreco_venda.setText(String.valueOf(i1.getPreco_venda()));
        jTTamanho.setText(i1.getTamanho());

    }
    
    private void novoCadastro(){

        Produto p1 = new Produto();
        p1.setNome(jTNome.getText());
        p1.setPreco_venda(Float.parseFloat(jTPreco_venda.getText()));
        p1.setTamanho(jTTamanho.getText());

         try {
            ProdutoDao dao = new ProdutoDao();
            dao.adiciona(p1);

            tmProduto.setNumRows(0);
            populaTabela("");

        } catch (SQLException ex) {
            Logger.getLogger(jFCadProduto.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void alteraCadastro(){

        Produto p1 = new Produto();
        p1.setId(Integer.parseInt(jTID.getText()));
        p1.setNome(jTNome.getText());
        p1.setTamanho(jTTamanho.getText());
        p1.setPreco_venda(Float.parseFloat(jTPreco_venda.getText()));

        try {
            ProdutoDao dao = new ProdutoDao();
            dao.altera(p1);
            tmProduto.setNumRows(0);
            populaTabela("");
        } catch (SQLException ex) {
            Logger.getLogger(jFCadProduto.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void removerCadastro(){
        
        Produto p1 = new Produto();
        p1.setId(Integer.parseInt(jTID.getText()));
        
        ProdutoDao dao;
        try {
            dao = new ProdutoDao();
            dao.remove(p1);
            tmProduto.setNumRows(0);
            populaTabela("");
        } catch (SQLException ex) {
            Logger.getLogger(jFCadProduto.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void limparCampos(){
        jTID.setText("");
        jTNome.setText("");
        jTPreco_venda.setText("");
        jTTamanho.setText("");
    }

    public void desabilitaDados(){
        jTID.setEditable(false);
        jTNome.setEditable(false);
        jTPreco_venda.setEditable(false);
        jTTamanho.setEditable(false);

    }

    public void habilitaDados(){
        jTNome.setEditable(true);
        jTPreco_venda.setEditable(true);
        jTTamanho.setEditable(true);

    }

    public boolean verificaDados(){

        if (!jTNome.getText().equals("")) {
            return true;
        } else {
            JOptionPane.showMessageDialog(null, "Campo nome não preenchido");
            return false;
        }
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {

            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBAlterar;
    private javax.swing.JButton jBExcluir;
    private javax.swing.JButton jBNovo;
    private javax.swing.JButton jBPesquisa;
    private javax.swing.JButton jBSair;
    private javax.swing.JButton jBSalvar;
    private javax.swing.JLabel jLEstoque;
    private javax.swing.JLabel jLID;
    private javax.swing.JLabel jLMarca;
    private javax.swing.JLabel jLNome;
    private javax.swing.JPanel jPCadProduto;
    private javax.swing.JPanel jPPesquisaNome;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTID;
    private javax.swing.JTextField jTNome;
    private javax.swing.JTextField jTPesquisa;
    private javax.swing.JTextField jTPreco_venda;
    private javax.swing.JTable jTProduto;
    private javax.swing.JTextField jTTamanho;
    // End of variables declaration//GEN-END:variables

}
